#include<bits/stdc++.h>
using namespace std;
int T,n;
int a[101];
int c[101];
bool vis[101];
int pow(int a,int b){
    int k=1;
    for(int i=1;i<=b;i++)k*=a;
    return k;
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        int total=0;
        memset(c,0,sizeof(c));
        memset(a,0,sizeof(a));
        memset(vis,0,sizeof(vis));
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i];
        int n2=pow(2,n);
        for(int i=0;i<n2;i++){
            int l=i,visi=1;
            while(l){
                vis[visi++]=l&1;
                l>>=1;
            }
            for(int j=2;j<=n;j++){
                for(int k=j-1;k>=1;k--){
                    // cout<<i<<" "<<j<<" "<<k<<endl;
                    if(vis[j]==vis[k]&&a[j]==a[k]){
                        c[j]=a[j];
                        break;
                    }
                }
            }
            int ans=0;for(int i=1;i<=n;i++)ans+=c[i];
            total=max(total,ans);
        }
        cout<<total<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}